<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
			<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>认证动态</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/news.css">
		<link rel="stylesheet" type="text/css" href="../../css/aui.css">
		<style type="text/css" media="screen">
			.noSign {
				margin-left: 50%;
				margin-top: 50%;
			}
			.course-img {
				/*background-image: url(../../image/course_placehoder.png);
				background-size: 100% 80px;*/
			}
		
		 	/**默认显示4行*/
.according-2-rows{
 	 
 	overflow: hidden;
 	text-overflow: ellipsis;
 	display: -webkit-box;
 	-webkit-line-clamp: 2;
 	-webkit-box-orient: vertical;
 	}

		</style>
	</head>
	<body>
		<div class="main">
			<ul class="mui-table-view" id="div_news">
			<!--<ul class="mui-table-view" >
				<li class="mui-table-view-cell" onclick="CheckNewClick(1)">
					<div class="item_left div_title_css_left" style="position:relative;">
						<span class="item_text_title base_content_font base_black_grey according-2-rows">不错广东省人才交流大会很不错</p> <span class="item_text_bz base_grey base_tag_font" style="position:absolute; bottom:0px;">2017-10-9</span>
					</div>
					<div class="item_right div_title_css_left">
						<div class="item_right_s course-img"><img src="image/icon_renzheng0.png" onerror="Imgnofind()" />
						</div>
					</div>
				</li>
				<li class="mui-table-view-cell" onclick="CheckNewClick(1)">
					<div class="item_left div_title_css_left" style="position:relative;">
						<span class="item_text_title base_content_font base_black_grey according-2-rows">不错广东省人才交流大会很不错不错广东省人才交流大会很不错不错广东省人才交流大会很不错不错广东省人才交流大会很不错不错广东省人才交流大会很不错不错广东省人才交流大会很不错</p> <span class="item_text_bz base_grey base_tag_font" style="position:absolute; bottom:0px;">2017-10-9</span>
					</div>
					<div class="item_right div_title_css_left ">
						<div class="item_right_s course-img"><img src="image/icon_renzheng0.png" onerror="Imgnofind()" />
						</div>
					</div>
				</li>
			</ul>-->
			</ul>
			<div class="noSign"   id="noData"  hidden="hidden">
				<img src="../../image/icon_img.png" width="60%">
				<p class="font16 top_15 base_dark_grey" >
					暂无数据
				</p>
			</div>
			<div class="loadFailure"  id="noNet" hidden="hidden">
				<img src="../../image/icon_img01.png" width="60%">
				<p class="" >
					数据加载失败
				</p>
				<p>
					请检查您的网络
				</p>
				<button type="button" class="mui-btn mui-btn-outlined" onclick="RefreshData()">
					重新加载
				</button>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		/*初始化为1*/
		var page = 1;
		var rows = 20;
		/*存储全局的数据*/
		var list = "";

		//当前内存中数据源
		var news_data = [];

		/*更新数据条数*/
		var loadedNewsLength = "";
		/*界面刚准备好的方法*/
		apiready = function() {
			setRefreshHeader();
			// setPullUpRefresh();

			/*显示提示框*/
			showProgress();

			loadNewData();

			//监听新闻列表点了状态栏,滚动到顶部通知
			api.addEventListener({
				name : 'scrollTopnNews'
			}, function(ret, err) {
				$('html,body').animate({scrollTop: '0px'}, 200);
			});
		}
		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				//加载最新数据
				loadNewData();
				//停止刷新控件
			});
		}

		// 上拉加载
		function setPullUpRefresh() {
			api.addEventListener({
				name : 'scrolltobottom'
			}, function(ret, err) {
				//加载更多数据
				loadMoreData();
			});
		}

		//加载最新数据
		function loadNewData() {
			page = 1;
			rows = 10;
			news_data = [];
			$('#div_news').html('');
			get_data();
		}

		//加载更多数据
		function loadMoreData() {
			page++;
			rows = 10;

			/*显示提示框*/
			showProgress();
			get_data();
		}

		//加载失败点击了刷新按钮
		function RefreshData() {
			$('#noNet').hide();
			//加载最新数据
			loadNewData();
		}

		/*请求数据*/
		function get_data() {
			/*参数*/
			var params = {
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage("cfnetppuid"),
				page : page,
				rows : rows,
				type : api.pageParam.type,
			};
		
			cfnetppPOST(url_getNewList, params, true, function(data, status) {
				api.hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						var responseData = data.data.list;
						if (responseData != null && responseData.length > 0) {
							$('#noData').hide();
 

                            multiplePicturesCache({
							   picArr : responseData,//包含图片数组
							   picKey : 'picpath',//图片对应的字段
						       isOriginals : 0 //是否源图1源图0缩略图，不传默认缩略图
							}, function(imageArr){
								// alert(JSON.stringify(imageArr));
								responseData = imageArr;
	                            newsInit(responseData, responseData.length);

	                            for (var i = 0; i < responseData.length; i++) {
									news_data.push(responseData[i]);
								}

							});

						} else {
							if (page == 1) {
								$('#div_news').html('');
							} else {
								// alert("没有更多数据了");
							}
						}
					} else {
						// $('#noData').show();
					}
				} else {
					$('#noNet').show();
				}
			});
		
		};

     function newsInit(datas,len){
     if (datas) {
		var news = '';
        var index = news_data.length;
	    for(var i=0;i<len;i++)    {
	    var data = datas[i];
	    var imgPath= datas[i].picpath;

        
        var xiabiao = index + i;
        // if (api.pageParam.type == 1) {   //新闻模块进来的

        	if(imgPath!=null&&imgPath!=""){   

               var news1=	'<li class="mui-table-view-cell train-cell"  onclick="CheckNewClicks(' + i+')">'+
					'<img class="hot-train-image" src="'+imgPath+'">'+
					'<div class="hot-train-title-div">'+
						'<p class="base_black_grey base_content_font train-title">'
							+escape2Html(data.title).replace(/&/g,'')+
						'</p>'+
						'<p class="base_grey base_tag_font hot-train-time">'+
							getCurrentDay(data.ctime)+'&nbsp;&nbsp;'+data.author+
						'</p>'+
					'</div>'+
				'</li>';
			}else{
			  var news1='<li class="mui-table-view-cell"><p class="item_text_title base_content_font base_black_grey" onclick="CheckNewClick(' + xiabiao+')">'+escape2Html(data.title).replace(/&/g,'')+'</p>'+
				'<p class="item_text_bz base_grey base_tag_font">'+getCurrentDay(data.ctime)+data.author+'&nbsp;&nbsp;'+'</p>'+
							'</div>'+
			'</li>';
			 }
   //      }else{          //认证中心进来的
   //      	var news1='<li class="mui-table-view-cell"><p class="item_text_title base_content_font base_black_grey" onclick="CheckNewClick(' + xiabiao+')">'+escape2Html(data.title).replace(/&/g,'')+'</p>'+
			// 	'<p class="item_text_bz base_grey base_tag_font">'+getCurrentDay(data.ctime)+data.author+'&nbsp;&nbsp;'+'</p>'+
			// 				'</div>'+
			// '</li>';
   //      }
	    
	    
		 news = news+news1;

        }
    	if (page == 1) {
			$('#div_news').html(news);
		} else {
			$('#div_news').append(news);
		}

        }
    }
		//新闻详情
		function CheckNewClicks(index) {
	
		   var adurl = news_data[index].appadurl;
           var type = adurl.indexOf('http');
			if (type != -1 ) {//包含http
            
				api.openWin({useWKWebView:true,
				name : 'certificationDetails',
				url : 'certificationDetails.html',
				pageParam : {
					news : news_data[index],
					sourceurl:api.pageParam.sourceurl, 
		            sourcetitle:api.pageParam.sourcetitle,
		            type:type,
		            Newstype:'certification'
				},
				progress :{  //设置进度条类型和样式
					type :'page',
					color :'#45C01A'
				},
			});
            }
            if (adurl.substring(adurl.length-4) == ".mp4"){
            	var connectionType = api.connectionType;
	            if (connectionType != 'wifi' && connectionType != 'none') {
	            	api.confirm({
	                    title: '提示',
	                    msg: '您当前处于移动数据网络下，是否继续播放',
	                    buttons: ['确定', '取消']
	                }, function(ret, err) {
	                    var index = ret.buttonIndex;
	                    if (index == 1) {//确定
	                        toPlayVideo(adurl,news_data[index].title);
	                    }
	                });
	            }else{
	            	toPlayVideo(adurl,news_data[index].title);
	            }

            }
       SendBehaviorTrajectoriesNotifi1(1, '岗位新闻', '150',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
		}
		function toPlayVideo (url,title) {
			var videoPlayer = api.require('videoPlayer');
			videoPlayer.play({
			    path : url,
			    texts: {
			        head: {
			            title: title
			        }
			    },
			    styles : {
			    	head : {
			    		backSize : 24,
			    		backImg : 'widget://image/vp_back.png',
			    		setSize : 24,
			    		setImg : 'widget://image/vp_more.png'
			    	},
			    	foot :{
			    		playSize : 24,
			    		playImg : 'widget://image/vp_play.png',
			    		pauseImg : 'widget://image/vp_pause.png',
			    		nextSize : 24,
			    		nextImg : 'widget://image/vp_next.png'
			    	}
			    }
			}, function(ret, err) {

			});
		}

	</script>
</html>